// pages/adminPaiHao/adminPaiHao.js
Page({
  data: {

  },
  onShow(){
    this.getNum()
  },
  getNum(){
    wx.cloud.database().collection('queue').doc(this.getTime_Id()).get()
    .then(res=>{
      console.log(res);
      this.setData({
        queue:res.data
      })
    })
    .catch(res=>{
      console.log('今日没有排号',res);
    })
  },
  getTime_Id(){
    let d = new Date();
    let month = d.getMonth() + 1 ;
    let date = d.getDate() + '';
    let year = d.getFullYear() + ''  ;
    if(month<=9){
      month = '0' + month
    }
    if(date<=9){
      date = '0' + date
    }
    return year + month + date
  },
  addQueueNum(){
   wx.cloud.callFunction({
     name:"queue",
     data:{
      id:this.getTime_Id(),
      action:'admin'
     }
   })
   .then(res=>{
     console.log('操作结果',res);
     this.getNum()
   })
  }
})